﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Unity.InterceptionExtension;

namespace ConsoleApplication1
{
    public class UnityDefaultInterceptorExtension : UnityContainerExtension
    {
        protected override void Initialize()
        {
           Container.AddNewExtension<Interception>();
           Context.Registering += this.Context_Registering;
        }

        void Context_Registering(object sender, RegisterEventArgs e)
        {
            var i = new Interceptor<InterfaceInterceptor>();
            i.AddPolicies(e.TypeFrom, e.TypeTo, e.Name, Context.Policies);

            var ib = new InterceptionBehavior(new UnityBehavior());
            ib.AddPolicies(e.TypeFrom, e.TypeTo, e.Name, Context.Policies);

        }
    }
}
